package com.jeesite.modules.announcement.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import jakarta.validation.constraints.Size;
import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

import java.io.Serial;

/**
 * announcementEntity
 * @author cele
 * @version 2025-08-20
 */
@Table(name="announcement", alias="a", label="announcement信息", columns={
		@Column(name="id", attrName="tid", label="id", isPK=true),
		@Column(name="title", attrName="title", label="title", queryType=QueryType.LIKE),
		@Column(name="content", attrName="content", label="content", queryType=QueryType.LIKE),
		@Column(name="media_urls", attrName="mediaUrls", label="存储JSON格式的媒体URL"),
		@Column(name="author_id", attrName="authorId", label="作者ID", isUpdateForce=true),
		@Column(name="tags", attrName="tags", label="逗号分隔的标签"),
		@Column(name="slug", attrName="slug", label="URL友好标识"),
		@Column(name="created_at", attrName="createdAt", label="created_at", isUpdateForce=true),
		@Column(name="updated_at", attrName="updatedAt", label="updated_at", isUpdateForce=true),
	}, orderBy="a.id DESC"
)
public class Announcement extends DataEntity<Announcement> {
	
	@Serial
	private static final long serialVersionUID = 1L;
	private Long tid;		// id
	private String title;		// title
	private String content;		// content
	private String mediaUrls;		// 存储JSON格式的媒体URL
	private Long authorId;		// 作者ID
	private String tags;		// 逗号分隔的标签
	private String slug;		// URL友好标识
	private Date createdAt;		// created_at
	private Date updatedAt;		// updated_at

	public Announcement() {
		this(null);
	}
	
	public Announcement(String id){
		super(id);
	}
	
	@JsonSerialize(using = ToStringSerializer.class)
	public Long getTid() {
		return tid;
	}

	public void setTid(Long tid) {
		this.tid = tid;
	}
	
	@Size(min=0, max=200, message="title长度不能超过 200 个字符")
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	
	public String getMediaUrls() {
		return mediaUrls;
	}

	public void setMediaUrls(String mediaUrls) {
		this.mediaUrls = mediaUrls;
	}
	
	public Long getAuthorId() {
		return authorId;
	}

	public void setAuthorId(Long authorId) {
		this.authorId = authorId;
	}
	
	public String getTags() {
		return tags;
	}

	public void setTags(String tags) {
		this.tags = tags;
	}
	
	public String getSlug() {
		return slug;
	}

	public void setSlug(String slug) {
		this.slug = slug;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
	public Date getUpdatedAt() {
		return updatedAt;
	}

	public void setUpdatedAt(Date updatedAt) {
		this.updatedAt = updatedAt;
	}
	
}